/*
 * Triangular.h
 *
 *  Created on: Jun 8, 2011
 *      Author: gilang
 */

#ifndef TRIANGULAR_H_
#define TRIANGULAR_H_
#include "Element.h"
#include <cmath>

class Triangular: public Element {
protected:

private:
	void init() {
		this->node = new Node[TRIANGULAR + 1];
		this->stiffMatrix = Matrix(TRIANGULAR, TRIANGULAR);
		this->loadVector = Vector(TRIANGULAR);
		this->convMatrix = Matrix(TRIANGULAR, TRIANGULAR);
		this->genVector = Vector(TRIANGULAR);
		this->convVector = Vector(TRIANGULAR);
		this->fluxVector = Vector(TRIANGULAR);
		this->last = false;
	}
public:
	Triangular();
	Triangular(const int &label);
	Triangular(Element *e);
	void setStiffMatrix(Matrix &m) {
		this->stiffMatrix = m;
	}
	void setLoadVector(Vector &v) {
		this->loadVector = v;
	}
	void setConvMatrix(Matrix &cm) {
		this->convMatrix = cm;
	}
	void setGenVector(Vector &g) {
		this->genVector = g;
	}
	void setFluxVector(Vector &f) {
		this->fluxVector = f;
	}
	void setConvVector(Vector &c) {
		this->convVector = c;
	}
	void setLabel(int &label) {
		this->label = label;
	}
	int & getLabel() {
		return label;
	}
	Matrix & getStiffMatrix() {
		return stiffMatrix;
	}
	Matrix & getConvMatrix() {
		return convMatrix;
	}
	Vector & getGenVector() {
		return genVector;
	}
	Vector & getFluxVector() {
		return fluxVector;
	}
	Vector & getConvVector() {
		return convVector;
	}
	Vector & getLoadVector() {
		return loadVector;
	}
	void setNode(Node *node) {
		this->node = node;
	}
	Node * getNode() {
		return node;
	}

	void addNode(int i, const Node &n);
	double dimLength();
	double operator()(int i, int j);
	double operator[](int i);
	Node & operator()(int i);
	Matrix constructLHS();
	Vector constructRHS();

	void setMaterial(const Material &mat) {
		this->material = mat;
	}
	Material & getMaterial() {
		return material;
	}

	void setNum(const int &num) {
		this->num = num;
	}
	int & getNum() {
		return num;
	}

	void setLast(bool last) {
		this->last = last;
	}
	bool isLast() {
		return last;
	}
	Vector & A();
	Vector & B();
	Vector & C();
	double exposedBoundary(int i,int j);
	virtual ~Triangular();
};

#endif /* TRIANGULAR_H_ */
